<?php
class MysqlDao{

	private $db_host="";
	private $db_username="";
	private $db_password="";
	private $db_name="";
	
	function __construct(){
		include('config.php');
		$this->db_host=$db_host;
		$this->db_username=$db_username;
		$this->db_password=$db_password;
		$this->db_name=$db_name;
	}

	function connect(){
		
		//生成一个连接
		$db_connect=@mysql_connect($this->db_host,$this->db_username,$this->db_password) or die("Unable to connect to the MySQL!");
		mysql_select_db($this->db_name, $db_connect);
		return $db_connect;
	}
	
	function addUser($name="" , $password=""){
		$db_connect = $this->connect();
		
		$sql = "insert into user(name,password) values('".$name."' , '".$password."')";
		$result = mysql_query($sql,$db_connect);
		
		return $result;
	}
	
	function getUser($name="" , $password=""){
		$db_connect = $this->connect();
		
		$sql = "select * from user where name='".$name."' and password='".$password."'";
		$result = mysql_query($sql,$db_connect);
		
		return $result;
	}
}
?>